package hivi.vn.hivigold.fragment;

import hivi.vn.hivigold.R;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageButton;


public class HomeFragment extends Fragment {
	public static final int FEATURE_SEARCHITEM = R.id.btnItem;
	public static final int FEATURE_GOLDPRICE = R.id.btnPrice;
	public static final int FEATURE_TRANSACTION = R.id.btnTransaction;
	public static final int FEATURE_PARTNER = R.id.btnPartner;
	public static final int FEATURE_REPORT = R.id.btnReport;
	public static final int FEATURE_SETTING = R.id.btnSetting;
	
	ImageButton btnItem;
	ImageButton btnPrice;
	ImageButton btnTransaction;
	ImageButton btnPartner;
	ImageButton btnReport;
	ImageButton btnSetting;
	
	HomeListener hl;
	
	public HomeFragment() {
		// TODO Auto-generated constructor stub
	}
	
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		View v =inflater.inflate(R.layout.home_layout, null);
		btnItem = (ImageButton)v.findViewById(R.id.btnItem);
		btnPrice = (ImageButton)v.findViewById(R.id.btnPrice);
		btnTransaction = (ImageButton)v.findViewById(R.id.btnTransaction);
		btnPartner = (ImageButton)v.findViewById(R.id.btnPartner);
		btnReport = (ImageButton)v.findViewById(R.id.btnReport);
		btnSetting = (ImageButton)v.findViewById(R.id.btnSetting);
		btnItem.setOnClickListener(onClick);
		btnPrice.setOnClickListener(onClick);
		btnPartner.setOnClickListener(onClick);
		btnSetting.setOnClickListener(onClick);
		btnReport.setOnClickListener(onClick);
		btnTransaction.setOnClickListener(onClick);
		return v;
	}
	
	OnClickListener onClick = new OnClickListener() {
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			if(hl != null)
			{
				hl.HomeClickListener(v.getId());	
			}
		}
	};
	
	public void setHomeListener(HomeListener hl)
	{
		this.hl = hl;
	}
	
	public static interface HomeListener
	{
		public void HomeClickListener(int feature);
	}
}
